import csv
import re

csv_file = open("movie-all.csv", "r", encoding="utf-8")
csv_reader = csv.reader(csv_file, delimiter=",", quotechar='"')
proc_file = open("movie-all-proc.csv", "w", encoding="utf-8")
proc_writer = csv.writer(proc_file, delimiter=",", quotechar='"')
proc_file.write("name,link,genre,director,actors,releaseTime,runTime,star\n")
next(csv_reader)
for row in csv_reader:
    releaseTime = row[5]
    runTime = row[6]
    star = row[7]
    re_date = re.compile(r"(\d{4})-?(\d{2})?-?(\d{2})?")
    re_time = re.compile(r"(\d+)")
    re_star = re.compile(r"(\d+\.\d+)")
    # print(releaseTime, runTime, star)
    releaseTime = re.search(re_date, releaseTime).group(0)
    runTime = re.search(re_time, runTime).group(0)
    star = re.search(re_star, star).group(0)
    print(releaseTime, runTime, star)
    proc_writer.writerow([row[0], row[1], row[2], row[3], row[4], releaseTime, runTime, star])
